package cn.sxt.yxl.controller.head;

import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.sxt.yxl.common.util.ConstatFinalUtil;
import cn.sxt.yxl.common.util.PageInfoUtil;
import cn.sxt.yxl.users.pojo.AAdmins;
import cn.sxt.yxl.users.service.IUsersService;

/**
 * 不需要登陆的Controller
 * 
 * @author wangshSxt
 *
 */
@Controller
public class NoLoginController
{
	@Resource
	private IUsersService usersService;

	/**
	 * 管理员列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "/adminsList",method = {RequestMethod.POST})
	public String adminsList(HttpServletRequest request)
	{
		ConstatFinalUtil.LOGGER.info("---- adminsList ---请求方式:method:{}--",request.getMethod());
		
		/* 如何获取请求头里面的内容 */
		Enumeration  enu = request.getHeaderNames();
		while(enu.hasMoreElements())
		{
			String key = enu.nextElement() + ""; 
			ConstatFinalUtil.LOGGER.info(key + "--header-->" + request.getHeader(key));
		}
		ConstatFinalUtil.LOGGER.info("---- ===== ---");
		/* 如何获取所有的参数 */
		Map<String, String[]> paramsMap = request.getParameterMap();
		for (Iterator iterator = paramsMap.entrySet().iterator(); iterator.hasNext();)
		{
			Entry me = (Entry) iterator.next();
			String key = me.getKey() + "" ; 
			String[] values = (String[]) me.getValue() ; 
			ConstatFinalUtil.LOGGER.info(key + "--parameter-->" + Arrays.toString(values));
		}
		
		/* 查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();

		PageInfoUtil pageInfoUtil = new PageInfoUtil();
		/*
		 * List<AAdmins> adminsList =
		 * this.usersService.findCondListAdminsService(null, condMap);
		 */
		List<AAdmins> adminsList = this.usersService.findCondListAdminsService(pageInfoUtil, condMap);
		request.setAttribute("adminsList", adminsList);
		return "/head/adminsList";
	}
}
